<template>
  <el-table :data="model.getList()" style="width: 100%;" @row-click="row => $emit('form', row)">
    <el-table-column :label="plugin.lang('form.code')" prop="code">
      <template #default="scope">
        <el-link type="primary" href="javascript:;">{{ scope.row.code }}</el-link>
      </template>
    </el-table-column>
    <el-table-column :label="plugin.lang('form.name')" min-width="150" prop="name">
      <template #default="scope">
        <div class="wrap">{{ scope.row.name }}</div>
      </template>
    </el-table-column>
    <el-table-column :label="plugin.lang('form.phone')" prop="phone" />
    <el-table-column :label="plugin.lang('form.email')" prop="email" />
    <el-table-column fixed="right" width="200">
      <template #default="scope">
        <div style="text-align: right">
          <el-popconfirm
            :title="lang.t('alert.delete')"
            @confirm="model.del(scope.row.id)"
            confirmButtonType="danger"
            placement="left"
            hideIcon
          >
            <template #reference>
              <el-button type="danger" size="small" @click.stop>{{ lang.t('common.delete') }}</el-button>
            </template>
          </el-popconfirm>
        </div>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import app from '@/app'
import model from '../model'

export default {
  setup() {
    // 加载数据
    model.get()
    
    return {
      lang: app.lang,
      plugin: app.plugin.index,
      model
    }
  }
}
</script>